package com.mxf.miaosha.redis;

public abstract class BasePrefix implements KeyPrefix {

    private int expireSeconds; // 过期时间

    private String prefix; // 前缀

    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }

    public BasePrefix(String prefix) {
        this(0, prefix);
    }

    @Override
    public int expireSeconds() {
        return expireSeconds; // 默认0永不过期
    }

    @Override
    public String getPrefix() {
        String className = getClass().getSimpleName(); // 获取类名
        return className + ":" + prefix;
    }
}
